const app = getApp(),url = app.globalData.url;
Page({

  /**
   * 页面的初始数据
   */
  data: {
		xueliArr:[],//学历
		xueindex:'',//学历
		companyArr:[],
		companyindex:'',
		industryArr:[],
		industryindex:'',
		natureArr:[],
		natureindex:'',
		wage_rangeArr:[],
		wage_rangeindex:'',

		xueli_size:'',// 学历
		company_size:'',
		industry:'',
		nature:'',
		wage_range:'',
  },

  onLoad: function (options) {
		var that = this
		// 学历要求 上传参数
		wx.request({
			url: url + 'dict/getEducationState',
			method:'get',
			data: {},
			success(res){
				that.setData({
					xueliArr:res.data.data,
				})
			},
			fail:function(res){
				console.log(res)
			}
		})
		// 企业规模 company_size 
		wx.request({
			url: url + 'dict/getEnterpriseSize',
			method:'get',
			data: {},
			success: function(res)
			{
				// console.log(res)
				that.setData({
					companyArr:res.data.data,
					// companyindex:res.data.data[0].id,
					// company_size:res.data.data[0].subTypeName
				})
			},
			fail:function(res){
				console.log(res)

			}
		})
		// 所属行业 industry 
		wx.request({
			url: url + 'occupation/getOccupationType',
			method:'get',
			data: {},
			success(res){
				that.setData({
					industryArr:[{id: '', name: '不限'}, ...res.data.data]
				})
			},
			fail:function(res){
				console.log(res)
			}
		})
		// 企业性质 nature 
		wx.request({
			url: url + 'dict/getEnterpriseNature',
			method:'get',
			data: {},
			success: function(res)
			{
				// console.log(res)
				that.setData({
					natureArr: res.data.data,
					// natureindex:res.data.data[0].id,
					// nature:res.data.data[0].subTypeName,
				})
			},
			fail:function(res){
				console.log(res)
			}
		})
		// 薪资范围 wage_range
		wx.request({
			url: url + 'dict/getWageRangeState',
			method:'get',
			data: {},
			success(res){
				that.setData({
					wage_rangeArr: [{id: '', subTypeName: '不限'}, ...res.data.data],
				})
			},
			fail:function(res){
				console.log(res)
			}
		})
		// 学历  查询接口目前没有
	},
	//学历
	xuelixueli(e){
		var that = this
		var id = e.currentTarget.dataset.id;
		var name = e.currentTarget.dataset.name;
		that.setData({
			xueindex:id,xueli_size:name,
		})
	},
	// 企业规模 选择
	butcomp(e){
		var that = this
		var id = e.currentTarget.dataset.id;
		var name = e.currentTarget.dataset.name;
		that.setData({
			companyindex:id,company_size:name,
		})
	},
	// 所属行业 选择
	butindus(e){
		var that = this
		var id = e.currentTarget.dataset.id;
		var name = e.currentTarget.dataset.name;
		// var companyArr = that.data.companyArr
		that.setData({
			industryindex:id,industry:name,
		})
	},
	// 企业性质 选择
	butnature(e){
		var that = this
		var id = e.currentTarget.dataset.id;
		var name = e.currentTarget.dataset.name;
		// var companyArr = that.data.companyArr
		that.setData({
			natureindex:id,
			nature:name,
		})
	},
	// 薪资范围 选择
	butwage(e){
		var that = this
		var id = e.currentTarget.dataset.id;
		var name = e.currentTarget.dataset.name;
		// var companyArr = that.data.companyArr
		that.setData({
			wage_rangeindex:id,wage_range:name,
		})
	},

	reset(){
		var that = this
		that.setData({
			xueindex:'',
			companyindex:'',
			industryindex:'',
			natureindex:'',
			wage_rangeindex:'',
			xueli_size:'',//学历
			company_size:'',
			industry:'',
			nature:'',
			wage_range:'',
		})
	},
	submit(){
		wx.setStorageSync('jl_search', this.data.searchForm)
		let pages = getCurrentPages();//当前页面栈
		let prePage = pages[pages.length - 2]
		prePage.reload()
		wx.navigateBack()
	},
	submit(){
		var uid = wx.getStorageSync('user_massage')
		var that = this
		var data={
			companySize:that.data.company_size,//公司规模
			industry:that.data.industry,//所属行业
			enterpriseNature:that.data.nature,//企业性质
			wageRange:that.data.wage_range,//薪资范围
			educational:that.data.xueli_size,//学历
			positionName:'',//职位名称
			pageNum :1,
			pageSize :70,
			userUid:uid.userUid ? uid.userUid : '' ,
		}
		for(let key in data){
			if(data[key] == '不限'){
				data[key] = ''
			}
		}
		// wx.setStorageSync('work_search', data)
		// let pages = getCurrentPages();//当前页面栈
		// let prePage = pages[pages.length - 2]
		// prePage.reload()
		// wx.navigateBack()

		wx.setStorageSync('objdata',data)
		wx.navigateTo({
			url: './searchlist/searchlist',
		})
	},
})